package com.rw.tool.util.expression.exception;

import com.rw.tool.util.expression.state.InfixExpressionState;

/**
 * 表达式解析异常
 */
public class InfixExpressionParseException extends InfixExpressionException {
    private final InfixExpressionState state;

    private final int index;

    private final String expression;

    public InfixExpressionParseException(InfixExpressionState state, String expression, int index) {
        super(getErrorMessage(state, index));
        this.state = state;
        this.expression = expression;
        this.index = index;
    }

    /**
     * 获取当前状态
     */
    public InfixExpressionState getState() {
        return state;
    }

    /**
     * 获取解析错误位置
     */
    public int getIndex() {
        return index;
    }

    /**
     * 获取表达式
     */
    public String getExpression() {
        return expression;
    }
}
